﻿<c:BookMarkViewBase x:Class="nyxwin.Main.View.Main.BookMarkView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:c="clr-namespace:nyxwin.Main.View.Main"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:converters="clr-namespace:nyxwin.Common.Silverlight.Converters;assembly=nyxwin.Common"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">
    <c:BookMarkViewBase.Resources>
        <converters:IsPositiveToVisibility x:Name="isPositiveToVisibility" />
        <Style x:Key="expandCheckBoxStyle" TargetType="CheckBox">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="CheckBox">
                        <Grid Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver" />
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="background">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="plus">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="minus">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Checked">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="plus">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unchecked">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="minus">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid Margin="6">
                                <Ellipse x:Name="background" Stroke="{StaticResource PhoneForegroundBrush}" StrokeThickness="2" />
                                <Path x:Name="plus" Width="36" Height="36" Data="M 10,18 L 26,18 M 18,10 L 18,26" Stroke="{StaticResource PhoneForegroundBrush}" StrokeThickness="2" />
                                <Path x:Name="minus" Width="36" Height="36" Data="M 10,18 L 26,18" Stroke="{StaticResource PhoneForegroundBrush}" StrokeThickness="2" />
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <DataTemplate x:Key="categoryTemplate">
            <Grid Margin="0,3,0,0">
                <Rectangle Fill="{StaticResource PhoneContrastBackgroundBrush}" Opacity="0.2" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="65,0">
                    <TextBlock Text="::" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Margin="0,0,10,0" />
                    <TextBlock Text="{Binding Path=Title}" FontSize="{StaticResource PhoneFontSizeMediumLarge}" />
                    <TextBlock Text="::" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Margin="10,0,0,0" />
                </StackPanel>
                <CheckBox HorizontalAlignment="Left" VerticalAlignment="Center" Style="{StaticResource expandCheckBoxStyle}" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay}" Margin="10,0,0,0" />
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="categoryPreviewTemplate">
            <Grid Margin="0,5">
                <Rectangle Fill="{StaticResource PhoneBackgroundBrush}" />
				<Rectangle Fill="{StaticResource PhoneContrastBackgroundBrush}" Opacity="0.2" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50,5">
                    <TextBlock Text="::" />
                    <TextBlock Text="{Binding Path=Title}" Style="{StaticResource PhoneTextNormalStyle}" />
                    <TextBlock Text="::" />
                </StackPanel>     	
            </Grid>
        </DataTemplate>
        <Style x:Key="bookMarkButtonTemplate" TargetType="Button">
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="Button">
        				<Grid Background="Transparent">
        					<VisualStateManager.VisualStateGroups>
        						<VisualStateGroup x:Name="CommonStates">
        							<VisualState x:Name="Normal"/>
        							<VisualState x:Name="MouseOver"/>
        							<VisualState x:Name="Pressed">
        								<Storyboard>
        									<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
        										<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneAccentBrush}"/>
        									</ObjectAnimationUsingKeyFrames>
        								</Storyboard>
        							</VisualState>
        							<VisualState x:Name="Disabled">
        								<Storyboard>
        									<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
        										<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
        									</ObjectAnimationUsingKeyFrames>
        								</Storyboard>
        							</VisualState>
        						</VisualStateGroup>
        					</VisualStateManager.VisualStateGroups>
        					<ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
        				</Grid>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
        <DataTemplate x:Key="bookmarkTemplate">
        	<Grid>
        		<Rectangle Fill="{StaticResource PhoneContrastBackgroundBrush}" Opacity="0.05" Margin="0,3" />
	        	<Grid Margin="0,6">
	        		<Grid.ColumnDefinitions>
	        			<ColumnDefinition Width="Auto" />
						<ColumnDefinition Width="Auto" />
						<ColumnDefinition Width="1*" />    		
					</Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="{Binding Unread}" Visibility="{Binding Unread, Converter={StaticResource isPositiveToVisibility}}" Style="{StaticResource PhoneTextAccentStyle}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4,-2,4,0" />
                    <TextBlock Grid.Column="1" Text="{Binding Replies}" Visibility="{Binding Replies, Converter={StaticResource isPositiveToVisibility}}" Style="{StaticResource PhoneTextAccentStyle}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4,-2,4,0" />
					<Button Content="{Binding Title}" Command="{Binding Path=OpenCommand}" Grid.Column="2" Style="{StaticResource bookMarkButtonTemplate}" FontSize="{StaticResource PhoneFontSizeNormal}" HorizontalContentAlignment="Left" />
				</Grid>
			</Grid>
        </DataTemplate>
    </c:BookMarkViewBase.Resources>

    <Grid>
    	<!-- GroupItemTemplate="{StaticResource categoryPreviewTemplate}" -->
		
        <toolkit:LongListSelector 
            IsFlatList="False"
            DisplayAllGroups="True"
            ItemsSource="{Binding Path=BookMarkCategories}" 
			GroupHeaderTemplate="{StaticResource categoryTemplate}" ItemTemplate="{StaticResource bookmarkTemplate}" 
			 />
        <!--<ListBox ItemsSource="{Binding Path=BookMarkCategories}" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="64" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{Binding Unread}" Style="{StaticResource PhoneTextAccentStyle}" />
                        <TextBlock Grid.Column="1" Text="{Binding Title}" Style="{StaticResource PhoneTextNormalStyle}" />
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>-->
    </Grid>
</c:BookMarkViewBase>
